package com.example.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.mapper.DepartmentMapper;
import com.example.model.Department;

@RestController
public class DeptController {

	@Resource
	DepartmentMapper departmentMapper;

	@GetMapping("/department/{id}")
	public Department getDepartmentById(@PathVariable("id") Integer id) {

		return departmentMapper.selectDepartmentById(id);
	}

	@PostMapping("/department")
	public Department saveDepartment(Department department) {
		departmentMapper.saveDepartment(department);
		return department;
	}

}
